import Ciallo from "@/api/Ciallo";
// 
export default function Ciallo2API(Mode) {
    const datas = arguments
    const urls = [
        "/directoryListAll",//查
        "/adddirectory",//增
        "/updatedirectory",//改
        "/deletedirectory",//删
        "/parent_directory",//查
    ]
    const fns = {
        "/directoryListAll": new Map([["page", datas[1]], ["limit", datas[2]], ["name", datas[3]]]),//查
        "/adddirectory": new Map([["pid", datas[1]], ["title", datas[2]], ["link", datas[3]]]),//增
        "/updatedirectory": new Map([["id", datas[1]], ["pid", datas[2]], ["title", datas[3]], ["link", datas[4]]]),//改
        "/deletedirectory": new Map([["ids", datas[1]]]),//删    
        "/parent_directory": new Map([]),//查  
    }

    const url = urls[Mode]
    const data = {}
    fns[url].forEach((k, v) => { Reflect.set(data, v, k) })
    const method = Mode == 4 ? "get" : "post"
    return Ciallo({
        url: url,
        method: method,
        params: { ...data }
    })
}